<%--
  Created by IntelliJ IDEA.
  User: asus
  Date: 2020/11/16
  Time: 20:19
  To change this template use File | Settings | File Templates.
--%>
<%@include file="../common/IncludeTop.jsp"%>

<%--<script type="text/javascript" src="${pageContext.request.contextPath}/js/register.js"></script>--%>
<%--<script>--%>
<%--    $(function () {--%>
<%--        $('#username').on('blur',function () {--%>
<%--            $.ajax({--%>
<%--              type      :"GET",--%>
<%--              url       :"usernameIsExistServlet?username=" +this.value,--%>
<%--              success   :function (data) {--%>
<%--                if (data === 'Exist'){--%>
<%--                    $('#usernameMsg').text = "用户名已存在";--%>
<%--                }--%>
<%--                else{--%>
<%--                    $('#usernameMsg').text = "用户名可用";--%>
<%--                }--%>
<%--              }--%>
<%--            });--%>
<%--        });--%>
<%--    });--%>
<%--</script>--%>
<%--<script>--%>
<%--    var xmlHttpRequest;--%>
<%--    function usernameIsExist() {--%>
<%--        //var username = document.NewAccountForm.username.value;--%>
<%--        var username = document.getElementById('username').value;--%>
<%--        xmlHttpRequest = new XMLHttpRequest();--%>
<%--        xmlHttpRequest.onreadystatechange = processResponse;--%>
<%--        xmlHttpRequest.open("GET","usernameIsExistServlet?username=" + username,true);--%>
<%--        xmlHttpRequest.send(null);--%>
<%--        // sendRequest("usernameIsExistServlet?username=" + username);--%>
<%--    }--%>
<%--    function processResponse() {--%>
<%--        if (xmlHttpRequest.readyState === 4) {--%>
<%--            if (xmlHttpRequest.status === 200) {--%>
<%--                var responseInfo = xmlHttpRequest.responseText--%>
<%--                // .getElementsByTagName("msg")[0].firstChild.data;--%>
<%--                var span1 = document.getElementById("usernameMsg");--%>
<%--                if (responseInfo === 'Exist') {--%>
<%--                    span1.innerText = "用户名已存在";--%>
<%--                } else {--%>
<%--                    span1.innerText = "用户名可用";--%>
<%--                }--%>
<%--            }--%>
<%--        }--%>
<%--    }--%>
<%--</script>--%>

${sessionScope.messageAccount}
<div id = "Catalog">
    <form action="newAccount" method="post">
        <h3>User Information</h3>
        <table>
            <tr>
                <td>User ID:</td>
                <td>
                    <input type="text" name="username" id="username" onblur="usernameIsExist();" >
<%--                    <span id="usernameMsg">hello</span>--%>
                    <div id="usernameMsg"></div>
                    <script type="text/javascript" src="${pageContext.request.contextPath}/js/register.js"></script>
                </td>
            </tr>
            <tr>
                <td>New Password:</td>
                <td><input type="text" name="password"/>
                </td>
            </tr>
            <tr>
                <td>Repeat Password:</td>
                <td><input type="text" name="repeatedPassword"/></td>
            </tr>
            <tr>
                <td>VerificationCode:</td>
                <td><input type="text" name="vCode" size="5" maxlength="4"/>
                <a href="newAccount"><img border="0" src="verificationCode" name = "checkcode"></a>
                </td>
            </tr>
        </table>
        <%@include file="IncludeAccountFields.jsp"%>
        <input type="submit" name="newAccount" value="Save Account Information"/>
    </form>

</div>
<%@include file="../common/IncludeBottom.jsp"%>
